<%--
  Created by IntelliJ IDEA.
  User: zll
  Date: 2018/5/30
  Time: 12:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>列表</title>

    <jsp:include page="../comm/comm.jsp"/>
</head>
<body>
<div class="layui-form" action="">

        <div class="layui-input-inline" style="width: 100px;">
            <button class="layui-btn layui-btn-warm" onclick="add()">添加</button>
        </div>
    </div>

<table id="demo" lay-filter="test"></table>


<script type="text/html" id="operate">
    <button class="layui-btn layui-btn-sm" onclick="modify('{{d.id}}')">修改</button>
    {{#  if(d.status==0){ }}
    <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="fabu('{{d.id}}')">取消发布</button>
    {{#  } else { }}
    <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="fabu('{{d.id}}')">发布</button>
    {{#  } }}
    {{#  if(d.type!=4){ }}
    <button class="layui-btn layui-btn-sm" onclick="userlist('{{d.id}}')">人员列表</button>
    {{#  } }}
    <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="deletes('{{d.id}}')">删除</button>
</script>
<script type="text/html" id="status">
    {{#  if(d.status==0){ }}
    已发布
    {{#  } else { }}
    未发布
    {{#  } }}
</script>
<script type="text/html" id="startDate">

    {{config.getTime(d.startDate) }}
</script>
<script type="text/html" id="endDate">

    {{config.getTime(d.endDate) }}
</script>
<script>
   function userlist(id) {
       //var  activityId=getQueryString("activityId");
       if(type=="0"||type=="1")
       location.href="/page/role/listtasks?type="+type+"&activityId="+id;
       else if(type=="2")
           location.href="/page/role/listsigns?activityId="+id;
       else if(type=="3")
           location.href="/page/role/listzhuli?activityId="+id;
   }

   function  modify(id) {
       if(type=="4")
           location.href="/page/role/listhuodong?activityId="+id;
       else {
       location.href="/activity/detail?type="+type+"&id="+id;
       }
   }
   function  deletes(id) {
       config.commPost("/activity/del",{id:id},function (data) {
           location.reload();
       })
       //location.href="/activity/detail?type="+type+"&id="+id;
   }
   function  fabu(id) {
       config.commPost("/activity/fabu",{id:id},function (data) {
           location.reload();
       })
       //location.href="/activity/detail?type="+type+"&id="+id;
   }
    function  add() {
        if(type=="4")
            location.href="/page/role/listhuodong?type="+type;
        else {
            location.href="/activity/detail?type="+type;
        }
    }

    var type=getQueryString("type");

    layui.use(['table','laydate'], function(){
        var laydate = layui.laydate;
        config.commGet("/role/getDates?type="+type,{},function (data) {
            $("#startDate").val(data.startDate);
            $("#endDate").val(data.endDate);
        })
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#demo'
            ,url: '/activity/listActivitys?type='+type //数据接口
            ,page: true //开启分页
            ,limits:[10]
            ,response: {
                statusName: 'status' //数据状态的字段名称，默认：code
                ,statusCode: 200 //成功的状态码，默认：0
                ,msgName: 'msg' //状态信息的字段名称，默认：msg
                ,countName: 'msg' //数据总数的字段名称，默认：count
                ,dataName: 'data' //数据列表的字段名称，默认：data
            }
            ,cols: [[ //表头
                {field: 'pagetitle', title: '页面标题',width:'8%'},
                {field: 'title', title: '标题',width:'8%'},
                {field: 'content', title: '内容',width:'10%'},
                {field: 'status', title: '状态',templet: '#status',width:'6%'},
                {field: 'startDate', title: '开始时间',templet: '#startDate',width:'10%'},
                {field: 'endDate', title: '结束时间',templet: '#endDate',width:'10%'},
                {field: 'createrTime', title: '创建时间',templet: '#date',width:'10%'},
                {field: 'url', title: '活动链接',width:'21%'},
                {field: 'createTime', title: '操作',templet: '#operate',width:'17%'},
            ]]
        });


    });
    function getQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
</script>
</body>
</html>
